package com.csdj.order.service;

import com.csdj.beans.entity.Goods;
import com.csdj.beans.interfaces.goods.IGoodsService;
import com.csdj.order.mapper.GoodsMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@DubboService
@Service
public class GoodsService implements IGoodsService {

    @Resource
    GoodsMapper goodsMapper;
    @Override
    public Goods getById(int id) {
        return goodsMapper.selectByPrimaryKey(id);
    }

    /**
     * 当quantity 大于0则是从库存中扣减，
     * 当quantity 小于0则是订单撤消库存加回
     * @param id
     * @param quantity
     * @return
     */
    @Override
    public boolean updateStorage(int id, int quantity) {
        return goodsMapper.updateStoreage(id,quantity)>0;
    }





}
